
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户权限管理</title>
    <link href="${pageContext.request.contextPath}/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f5f5f5;
            font-family: 'Microsoft YaHei', sans-serif;
        }
        .container {
            padding: 20px;
            animation: fadeIn 0.5s ease-out;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .table-wrapper {
            background: white;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.08);
            overflow: hidden;
            transition: all 0.3s;
        }
        .table-wrapper:hover {
            box-shadow: 0 8px 24px rgba(0,0,0,0.12);
        }
        .table th {
            background: #f8f9fa;
            position: sticky;
            top: 0;
            z-index: 10;
        }
        .table tr {
            transition: all 0.2s;
        }
        .table tr:hover {
            background-color: rgba(0,123,255,0.05);
            transform: translateX(4px);
        }
        .btn-action {
            transition: all 0.3s;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        .btn-action:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0,0,0,0.2);
        }
        .btn-delete {
            position: relative;
            overflow: hidden;
        }
        .btn-delete:after {
            content: "";
            position: absolute;
            top: 50%;
            left: 50%;
            width: 5px;
            height: 5px;
            background: rgba(255,255,255,0.5);
            opacity: 0;
            border-radius: 100%;
            transform: scale(1, 1) translate(-50%, -50%);
            transform-origin: 50% 50%;
        }
        .btn-delete:focus:after {
            animation: ripple 1s ease-out;
        }
        @keyframes ripple {
            0% { transform: scale(0, 0); opacity: 1; }
            100% { transform: scale(20, 20); opacity: 0; }
        }
        .pagination .page-item.active .page-link {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            border-color: transparent;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2 class="mb-4 text-center" style="color: #343a40; text-shadow: 1px 1px 2px rgba(0,0,0,0.1);">
            用户权限管理系统
        </h2>
        
        <div class="table-wrapper">
            <form id="userForm" action="${pageContext.request.contextPath}/admin/deleteMulti" method="post">
                <table class="table table-hover">
                    <thead class="thead-light">
                        <tr>
                            <th width="5%"><input type="checkbox" id="selectAll"></th>
                            <th width="5%">序号</th>
                            <th>卡号</th>
                            <th>用户名</th>
                            <th>套餐</th>
                            <th>预存金额</th>
                            <th>状态</th>
                            <th width="15%">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <c:forEach var="user" items="${pagehelper.list}" varStatus="vs">
                            <tr>
                                <td><input type="checkbox" name="ids" value="${user.id}"></td>
                                <td>${vs.count}</td>
                                <td>${user.card_number}</td>
                                <td>${user.username}</td>
                                <td>${user.planName}</td>
                                <td>${user.prepaid_amount}</td>
                                <td><span class="badge badge-pill badge-${user.statusName == '正常' ? 'success' : 'danger'}">${user.statusName}</span></td>
                                <td>
                                    <a href="${pageContext.request.contextPath}/admin/update_user?id=${user.id}" 
                                       class="btn btn-sm btn-primary btn-action mr-2">修改</a>
                                    <button type="button" class="btn btn-sm btn-danger btn-action btn-delete" 
                                            onclick="confirmDelete('${user.id}','${user.username}')">删除</button>
                                </td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>
                
                <div class="p-3 bg-light">
                    <button type="button" class="btn btn-danger mr-3" onclick="confirmMultiDelete()">
                        <i class="fas fa-trash-alt mr-2"></i>删除所选
                    </button>
                    <a href="plxg" class="btn btn-success mr-3">
                        <i class="fas fa-edit mr-2"></i>批量修改
                    </a>
                    <button type="button" class="btn btn-secondary" onclick="history.go(-1)">
                        <i class="fas fa-arrow-left mr-2"></i>返回
                    </button>
                    
                    <div class="float-right">
                        <%@include file="pagehelper_plsc.jsp" %>
                    </div>
                </div>
            </form>
        </div>
    </div>

    <script src="${pageContext.request.contextPath}/static/js/jquery-3.6.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
    <script>
        $(function(){
            // 全选/取消全选
            $('#selectAll').click(function(){
                $('input[name="ids"]').prop('checked', this.checked);
            });

            // 行点击效果
            $('tbody tr').click(function(e) {
                if(e.target.type !== 'checkbox' && e.target.tagName !== 'A' && e.target.tagName !== 'BUTTON') {
                    const checkbox = $(this).find('input[type="checkbox"]');
                    checkbox.prop('checked', !checkbox.prop('checked'));
                }
            });
        });

        function confirmDelete(id, name) {
            if(confirm('确定要删除用户【${name}】吗？')) {
                window.location.href = '${pageContext.request.contextPath}/admin/delete?id=' + id;
            }
        }

        function confirmMultiDelete() {
            const checked = $('input[name="ids"]:checked').length;
            if(checked === 0) {
                alert('请至少选择一项');
                return;
            }
            if(confirm('确定要删除选中的${checked}条记录吗？')) {
                $('#userForm').submit();
            }
        }
    </script>
</body>
</html>
<code_end>